home *** CD-ROM | disk | FTP | other *** search
/ Virtual Vibrations / Virtual Vibrations.iso / mac / Virtual Vibrations / STAR.DXR / 00005.ls < prev    next >
Encoding:
Text File  |  1994-10-28  |  6.8 KB  |  237 lines

  1. global gmovie, gorderlist, flag, hiliteline, currentselection, currentquant, currentname, ship, shippref, temprect, subprice, stax, quantcount, moviecount, titlecount, subtot, subtotal, mouseloc, position, disc
  2.  
  3. on checkquant
  4.   global flag, gorderlist
  5.   set flag to 0
  6.   repeat with t = 1 to count(gorderlist)
  7.     set currentname to getPropAt(gorderlist, t)
  8.     set currentquant to getProp(gorderlist, currentname)
  9.     if currentselection = string(currentname) then
  10.       queryquant()
  11.       exit repeat
  12.     end if
  13.   end repeat
  14.   if flag = 0 then
  15.     addProp(gorderlist, string(currentselection), 1)
  16.     formatlist()
  17.   end if
  18. end
  19.  
  20. on queryquant
  21.   set currentquant to currentquant + 1
  22.   setaProp(gorderlist, currentname, currentquant)
  23.   set flag to 1
  24.   formatlist()
  25. end
  26.  
  27. on formatlist
  28.   set templist to EMPTY
  29.   set tempprodlist to EMPTY
  30.   set temppricelist to EMPTY
  31.   set temppricelist2 to EMPTY
  32.   set tempsub to 0
  33.   set subtot to 0
  34.   set pricelist2 to EMPTY
  35.   sort(gorderlist)
  36.   repeat with t = 1 to count(gorderlist)
  37.     set tempquant to getAt(gorderlist, t)
  38.     if tempquant <= 0 then
  39.       deleteProp(gorderlist, t)
  40.       next repeat
  41.     end if
  42.     set currentitem to tempquant & " - "
  43.     set tempname to getPropAt(gorderlist, t)
  44.     put tempname after currentitem
  45.     put string(currentitem) & RETURN after templist
  46.     repeat with n = 1 to titlecount
  47.       set priceline to getAt(pricelist, n)
  48.       set lengthoftitle to the number of chars in priceline
  49.       set testtitle to chars(priceline, 23, lengthoftitle)
  50.       if testtitle = tempname then
  51.         set tempprod to chars(priceline, 1, 3)
  52.         put tempprod & RETURN after tempprodlist
  53.         set valtempprice to chars(priceline, 16, 20)
  54.         set tempprice to value(valtempprice * 1.00000999999999984)
  55.         put "$" & tempprice & RETURN after temppricelist
  56.         set tempprice2 to value(tempprice * tempquant * 1.00000999999999984)
  57.         set tempsub to value(tempsub + tempprice2)
  58.         put "$" & tempprice2 & RETURN after temppricelist2
  59.         exit repeat
  60.       end if
  61.     end repeat
  62.   end repeat
  63.   set the text of cast "orderlist" to templist
  64.   set the text of cast "prodnos" to tempprodlist
  65.   set the text of cast "prices" to temppricelist
  66.   set the text of cast "prices2" to temppricelist2
  67.   set subtot to value(tempsub)
  68. end
  69.  
  70. on calcsub
  71.   set quantcount to 0
  72.   set subtotal to 0
  73.   set tempprice to 0
  74.   repeat with t = 1 to count(gorderlist)
  75.     set counter to getAt(gorderlist, t)
  76.     set quantcount to quantcount + counter
  77.   end repeat
  78.   if quantcount >= 6 then
  79.     set discrate to 0.25
  80.   else
  81.     if quantcount = 5 then
  82.       set discrate to 0.19999999999999998
  83.     else
  84.       if quantcount = 4 then
  85.         set discrate to 0.14999999999999999
  86.       else
  87.         if quantcount = 3 then
  88.           set discrate to 0.09999999999999999
  89.         else
  90.           if quantcount <= 2 then
  91.             set discrate to 0.0
  92.           end if
  93.         end if
  94.       end if
  95.     end if
  96.   end if
  97.   set disc to value(subtot * discrate)
  98.   set the text of cast "discount" to "$" & disc
  99.   set the text of cast "subtotal" to "$" & subtot
  100. end
  101.  
  102. on calctax
  103.   if the hilite of cast "State" = 1 then
  104.     set stax to value(0.06 * subtot)
  105.   else
  106.     set stax to 0
  107.   end if
  108.   set the text of field "tax" to "$" & stax
  109. end
  110.  
  111. on calctotal
  112.   global subtot, disc, ship, stax
  113.   if shippref = 1 then
  114.     if (quantcount > 0) and (quantcount < 5) then
  115.       set ship to 4.5
  116.       set the text of cast "shipping" to "$4.50"
  117.     else
  118.       if (quantcount >= 5) and (quantcount < 9) then
  119.         set ship to 5.5
  120.         set the text of cast "shipping" to "$5.50"
  121.       else
  122.         if quantcount > 8 then
  123.           set ship to 6.0
  124.           set the text of cast "shipping" to "$6.00"
  125.         end if
  126.       end if
  127.     end if
  128.   end if
  129.   if shippref = 2 then
  130.     if (quantcount > 0) and (quantcount < 5) then
  131.       set ship to 7.5
  132.       set the text of cast "shipping" to "$7.50"
  133.     else
  134.       if (quantcount >= 5) and (quantcount < 9) then
  135.         set ship to 8.5
  136.         set the text of cast "shipping" to "$8.50"
  137.       else
  138.         if quantcount > 8 then
  139.           set ship to 9.0
  140.           set the text of cast "shipping" to "$9.00"
  141.         end if
  142.       end if
  143.     end if
  144.   end if
  145.   if shippref = 3 then
  146.     if (quantcount > 0) and (quantcount < 5) then
  147.       set ship to 16.75
  148.       set the text of cast "shipping" to "$16.75"
  149.     else
  150.       if (quantcount >= 5) and (quantcount < 9) then
  151.         set ship to 18.0
  152.         set the text of cast "shipping" to "$18.00"
  153.       else
  154.         if quantcount > 8 then
  155.           set ship to 19.0
  156.           set the text of cast "shipping" to "$19.00"
  157.         end if
  158.       end if
  159.     end if
  160.   end if
  161.   set total to value(subtot - disc + ship + stax)
  162.   set the text of cast "total" to "$" & total
  163. end
  164.  
  165. on orderbrowse
  166.   if not (hiliteline = the mouseLine) then
  167.     set hiliteline to the mouseLine
  168.   end if
  169. end
  170.  
  171. on ordermod
  172.   set position to 0
  173.   if (mouseloc > 218) and (mouseloc < 396) then
  174.     if mouseloc < 234 then
  175.       set position to 1
  176.     else
  177.       if (mouseloc < 251) and (count(gorderlist) >= 2) then
  178.         set position to 2
  179.       else
  180.         if (mouseloc < 267) and (count(gorderlist) >= 3) then
  181.           set position to 3
  182.         else
  183.           if (mouseloc < 283) and (count(gorderlist) >= 4) then
  184.             set position to 4
  185.           else
  186.             if (mouseloc < 299) and (count(gorderlist) >= 5) then
  187.               set position to 5
  188.             else
  189.               if (mouseloc < 315) and (count(gorderlist) >= 6) then
  190.                 set position to 6
  191.               else
  192.                 if (mouseloc < 331) and (count(gorderlist) >= 7) then
  193.                   set position to 7
  194.                 else
  195.                   if (mouseloc < 347) and (count(gorderlist) >= 8) then
  196.                     set position to 8
  197.                   else
  198.                     if (mouseloc < 363) and (count(gorderlist) >= 9) then
  199.                       set position to 9
  200.                     else
  201.                       if (mouseloc < 379) and (count(gorderlist) >= 10) then
  202.                         set position to 10
  203.                       else
  204.                         if (mouseloc < 396) and (count(gorderlist) >= 11) then
  205.                           set position to 11
  206.                         end if
  207.                       end if
  208.                     end if
  209.                   end if
  210.                 end if
  211.               end if
  212.             end if
  213.           end if
  214.         end if
  215.       end if
  216.     end if
  217.   end if
  218.   if not (position = 0) then
  219.     set currentname to getPropAt(gorderlist, position)
  220.     set currentquant to getAt(gorderlist, position)
  221.     hilite line position of field "orderlist"
  222.   end if
  223. end
  224.  
  225. on subtractorder
  226.   if not (position = 0) then
  227.     if currentquant = 1 then
  228.       deleteProp(gorderlist, currentname)
  229.     else
  230.       set currentquant to currentquant - 1
  231.       setaProp(gorderlist, currentname, currentquant)
  232.     end if
  233.     formatlist()
  234.     calcsub()
  235.   end if
  236. end
  237.